
<template>
  <div class="content_index">
    <div class="ci_header">
      <div class="ci_left sec-title">
        <el-icon
          style="vertical-align: middle; display: unset; cursor: pointer"
          @click="backList()"
          ><Back
        /></el-icon>
        <!-- <span>{{ route.name }}</span> -->
        <span>发证方信息</span>
      </div>
    </div>
    <div class="ci_content" style="margin: 12px 16px">
      <el-form
        ref="DetailFormRef"
        label-width="140px"
        :model="DetailForm"
        style="width: calc(100% - 16px)"
      >

        <el-form-item label="名称：">
          {{ DetailObj.name }}
        </el-form-item>
        <el-form-item label="DID：">
          {{ DetailObj.did }}
        </el-form-item>
        <el-form-item label="状态：">
          {{
            DetailObj.status === "0"
              ? "待审核"
              : DetailObj.status === "1"
              ? "正常"
              : DetailObj.status === "2"
              ? "停用"
              : "--"
          }}
          <el-button
            v-if="DetailObj.status === '0'"
            style="margin-left: 10px"
            @click.prevent="checkSign"
            type="primary"
            >审核</el-button
          >
        </el-form-item>
        <el-form-item label="签发类型：">
          {{ type[DetailObj.serviceType] }}
        </el-form-item>
        <el-form-item label="公钥：">
          {{ DetailObj.pubKey }}
        </el-form-item>
        <el-form-item label="创建时间：">
          {{ DetailObj.createdTime }}
        </el-form-item>
        <el-form-item label="编号：">
          {{ DetailObj.id }}
        </el-form-item>
        <el-form-item label="服务地址：">
          {{ DetailObj.endpoint }}
        </el-form-item>
        <el-form-item label="简单描述：">
          {{ DetailObj.shortDescription }}
        </el-form-item>
        <el-form-item label="详细描述：">
          {{ DetailObj.longDescription }}
        </el-form-item>
        <el-form-item>
          <el-dialog
            title="发证方审核"
            :close-on-click-modal="false"
            :modelValue="checkSignDialogVisible"
            :destroy-on-close="true"
            @close="clearSignForm"
          >
            <div slot="footer" class="dialog-footer center">
              <el-button @click.prevent="Pass(DetailObj.id, '1')" type="primary"
                >通过</el-button
              >
              <el-button plain @click="Pass(DetailObj.id, '2')"
                >不通过</el-button
              >
            </div>
          </el-dialog>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
  <script setup>
import { reactive, ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { lssuerDetailApi, lssuerUpdateApi } from "@/api/RegisterCenter";
import { ElMessage } from "element-plus";
import { deepJSON } from "@/utils/tool";
const router = useRouter();
const route = useRoute();
const checkSignDialogVisible = ref(false);
const backList = () => {
  router.go(-1);
};
const type = reactive({
  "00": "实名认证",
  // FingerprintAuthentication: "指纹认证",
  // EnterpriseAuthentication: "企业认证",
  // BusinessAuthentication: "商户认证",
  // VIPAuthentication: "大客户认证",
});
const DetailForm = reactive({});
const DetailObj = ref({});
const AdminLssuerInfo = async () => {
  let parmars = {
    id: route.query.id,
  };
  const { success, msg, data } = await lssuerDetailApi(parmars);
  if (success) {
    DetailObj.value = data.content[0] || {};
    // formatTxContent.value = deepJSON({}, JSON.parse(DetailObj.value.txContent));
  } else {
    ElMessage.error(msg || "明细获取失败,请稍后再试");
  }
};
const clearSignForm = () => {
  checkSignDialogVisible.value = false;
};
const checkSign = async () => {
  checkSignDialogVisible.value = true;
};
const Pass = (id, status) => {
  checkSignDialogVisible.value = false;
  let parmars = {
    id,
    status,
  };
  lssuerUpdateApi(parmars)
    .then((res) => {
      if (res.success) {
        ElMessage.success(res.msg || "正常");
        router.push({ path: "/RegisterCenter/LssuerList" });
      } else {
        router.push({ path: "/RegisterCenter/LssuerList" });
        ElMessage.error(res.msg || "停用");
      }
    })
    .catch((err) => {
      ElMessage.error(err.msg);
      router.push({ path: "/RegisterCenter/LssuerList" });
    });
};
onMounted(() => {
  AdminLssuerInfo();
});
</script>
  
  <style lang="scss" scoped>
@import "../../assets/css/cindex.scss";
:deep .el-upload-list--picture-card .el-upload-list__item-actions span + span {
  margin-left: 0.5em;
}
.add_icon {
  font-size: 18px;
  // margin-left: 10px;
  cursor: pointer;
  height: 100%;
}
.delete_icon {
  font-size: 18px;
  margin-left: 10px;
  cursor: pointer;
  height: 100%;
}
.box {
  display: flex;
  .left_txContent {
    // width: 200px;
    width: 50%;
    padding: 20px;
    // height: 200px;
    // background: pink;
    border-radius: 8px;
    border: 1px solid #d6e9c6;
    word-break: break-word;
    margin-right: 10px;
  }
  .rigth_txContent {
    width: 50%;
    padding: 20px;

    // width: 200px;
    // height: 200px;
    // background: red;
    border-radius: 8px;
    border: 1px solid #d6e9c6;
    word-break: break-word;
  }
}
.file_cn {
  // width: 130px;
  width: 100%;
  font-size: 14px;
  //   text-align: right;
  // margin-left: 70px;
  margin-bottom: 5px;
  padding: 10px;
  border-radius: 4px;
  border: 1px dashed #a6a6a6;
  div {
    margin-bottom: 15px;
  }
}
.Sign_content {
  display: flex;
  font-size: 14px;
  .Sign_content_key {
    display: inline-flex;
    justify-content: flex-end;
    align-items: flex-start;
    flex: 0 0 auto;
    height: 32px;
    line-height: 32px;
    padding: 0 12px 0 0;
    box-sizing: border-box;
    width: 90px;
  }
  .Sign_content_data {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
    line-height: 32px;
    position: relative;
    min-width: 0;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
}

.red {
  color: red;
}
.green {
  color: green;
}
.el-form-item .el-form-item {
  width: 100%;
  margin-bottom: 20px;
}
.wordWrap {
  word-break: break-word;
}
:deep .el-descriptions .el-descriptions__label {
  display: inline-block;
  width: 100px;
  text-align: right;
}
</style>